package admin.Service;

import java.sql.SQLException;
import java.util.ArrayList;

import admin.DAO.EmployeeDAO;
import admin.DTO.EmployeeDTO;

public class EmployeeServiceImpl implements EmployeeService{
	private EmployeeDAO dao;
	
	public EmployeeServiceImpl(EmployeeDAO dao){
		this.dao = dao;
	}

	@Override
	public EmployeeDTO login(EmployeeDTO dto) throws SQLException {
		return dao.login(dto);
	}

	@Override
	public void employeeJoin(EmployeeDTO dto) throws SQLException {
		dto.setEmployee_register(dto.getRegistration_number1().concat(dto.getRegistration_number2()));
		dto.setEmployee_hp(dto.getPhone_no01().concat(dto.getPhone_no02().concat(dto.getPhone_no03())));
		dao.employeeJoin(dto);
	}

	@Override
	public ArrayList<EmployeeDTO> searchEmployee(EmployeeDTO dto) throws SQLException {
		return dao.searchEmployee(dto);
	}

	@Override
	public EmployeeDTO employeeDetial(EmployeeDTO dto) throws SQLException {
		return dao.employeeDetial(dto);
	}

	@Override
	public int employeeModify(EmployeeDTO dto) throws SQLException {
		dto.setEmployee_register(dto.getRegistration_number1().concat(dto.getRegistration_number2()));
		dto.setEmployee_hp(dto.getPhone_no01().concat(dto.getPhone_no02().concat(dto.getPhone_no03())));
		return dao.employeeModify(dto);
	}

	@Override
	public void employeeDelete(int no) throws SQLException {
		dao.employeeDelete(no);
	}
}
